define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'yl/vips/index' + location.search,
                    add_url: 'yl/vips/add',
                    edit_url: 'yl/vips/edit',
                    del_url: 'yl/vips/del',
                    multi_url: 'yl/vips/multi',
                    import_url: 'yl/vips/import',
                    table: 'yl_vips',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                escape:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'member_id', title: __('Member_id')},
                        {field: 'vip_config_id', title: __('Vip_config_id')},
                        //{field: 'is_vip', title: __('Is_vip'), searchList: {"1":__('Is_vip 1'),"0":__('Is_vip 0')}, formatter: Table.api.formatter.normal},
                        //{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
                        {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate',cellStyle: {css: {
                                    "max-width": "300px",
                                }}, title: __('Operate'),buttons:[
                                {
                                    name:'list',
                                    text:__("申请会员判断"),
                                    title:__("申请会员判断"),
                                    url:'yl/vips/vips_panduan/type/11',
                                    classname: 'btn btn-xs btn-warning btn-magic btn-ajax',
                                    icon: '',
                                    confirm: '确定要通过申请吗',
                                    refresh: true,
                                    hidden: function (row) {
                                        if (row.status == 0) {
                                            return false;
                                        } else {
                                            return true;
                                        }
                                    },
                                }
                            ] ,table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
